# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Simon Sapin <simon dot sapin at exyr dot org>

pkgbase=python-cssselect
pkgname=('python-cssselect' 'python2-cssselect')
pkgver=1.0.1
pkgrel=1
license=('BSD')
arch=('any')
url="http://pypi.python.org/pypi/cssselect"
makedepends=('python-setuptools' 'python2-setuptools' 'git')
checkdepends=('python-pytest-runner' 'python2-pytest-runner' 'python-lxml' 'python2-lxml')
source=("git+https://github.com/scrapy/cssselect.git#tag=v$pkgver")
md5sums=('SKIP')

prepare() {
  cp -a cssselect{,-py2}
}

build() {
  cd "$srcdir"/cssselect
  python setup.py build

  cd "$srcdir"/cssselect-py2
  python2 setup.py build
}

check() {
  cd "$srcdir"/cssselect
  python setup.py ptr

  cd "$srcdir"/cssselect-py2
  python2 setup.py ptr
}

package_python-cssselect() {
  pkgdesc="A Python3 library that parses CSS3 Selectors and translates them to XPath 1.0"
  depends=('python')

  cd cssselect
  python setup.py install --root="$pkgdir" --optimize=1

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

package_python2-cssselect() {
  pkgdesc="A Python2 library that parses CSS3 Selectors and translates them to XPath 1.0"
  depends=('python2')

  cd cssselect-py2
  python2 setup.py install --root="$pkgdir" --optimize=1
  
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
